package cn.dankal.flyaudio.adapter;

import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import cn.dankal.basiclib.base.recyclerview.BaseRecyclerViewAdapter;
import cn.dankal.basiclib.base.recyclerview.BaseRecyclerViewHolder;
import cn.dankal.basiclib.pojo.LogisticsEntity;
import cn.dankal.flyaudio.R;
import cn.dankal.flyaudio.friend.pickimage.StringUtil;

/**
 * <pre>
 *     e-mail : junfeng.nie@duntech.com.cn
 *     time   : 23/7/2020
 *     desc   :
 *     version: cn.dankal.flyaudio.adapter
 *     Copyright: Copyright（c）2018
 *     Company:
 * </pre>
 *
 * @author niejunfeng
 */
public class LogisticsAdapter extends BaseRecyclerViewAdapter<LogisticsEntity> {
    @Override
    protected int getLayoutResId(int viewType) {
        return R.layout.item_logistics;
    }

    private String type;

    public LogisticsAdapter() {
    }

    public LogisticsAdapter(String type) {
        this.type = type;
    }

    @Override
    protected BaseRecyclerViewHolder getViewHolder(ViewGroup parent, View rootView, int viewType) {
        return new LogisticsAdapter.ViewHolder(rootView);
    }

    class ViewHolder extends BaseRecyclerViewHolder<LogisticsEntity> {

        public ViewHolder(View itemView) {
            super(itemView);
        }

        @Override
        public void onBindData(LogisticsEntity data, int position) {
            setText(R.id.item_tv_content, data.getContent());
            String time = "";
            if (StringUtil.isEmpty(data.getCreatedDatetime())) {
                time = "";
            } else {
                time = data.getCreatedDatetime();
            }
            setText(R.id.item_tv_time, time);
            ImageView ivCircle = itemView.findViewById(R.id.item_iv_circle);
            if (StringUtil.isEmpty(type)) {
                ivCircle.setSelected(position == 0);
            } else {
                if (position == (Integer.valueOf(type))) {
                    ivCircle.setImageResource(R.drawable.ret_cc1f1e);
                } else {
                    ivCircle.setImageResource(R.drawable.select_0085b4_7f0085b4);
                }
            }

        }
    }
}


